#ifndef HASIO_DETAIL_EXECUTOR_OP_HPP
#define HASIO_DETAIL_EXECUTOR_OP_HPP

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)

#include "scheduler_operation.hpp"

namespace hasio {
namespace detail {

template<typename Handler,
    typename Operation = scheduler_operation>
class executor_op
    : public Operation
{
public:
    executor_op(Handler handler)
        : Operation(&executor_op::do_complete)
        , handler_(handler)
    {
    }

    static void do_complete(Operation* base)
    {
        executor_op* op = static_cast<executor_op*>(base);
        op->handler_();
    }
private:
    Handler handler_;
};

}
}

#endif // HASIO_DETAIL_EXECUTOR_OP_HPP